<!doctype html>
<uieip type="page" value="login"></uieip>
<uieip type="reg" value="console"></uieip>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>cms model edit</title>
    <uieip type="file" value="inc" src="/yqwin/easyui/include.txt" cache="true" minute="1440"></uieip>
    <uieip type="file" value="css" src="/yqwin/css/yqwin.min" cache="false"></uieip>
    <uieip type="file" value="js" src="/yqwin/src/yqwin.min" cache="false"></uieip>
</head>

<body style="margin: 0px;">
    <div id="editor" style="width: 100%;height:400px;">some text</div>
    <script>
        $(function () {
            var path = $.urlRequest("path");
            var mobile = $.urlRequest("mobile");
            fileinfo_cms(path, mobile, function (res) {
                console.log(res);
                if (res.error == 0) {
                    $("#editor").yqFileEdit({
                        data: res.data,
                        width: $(window).width(),
                        height: $(window).height()-1,
                    });

                    
                    $(window).resize(function () {
                        onresize();
                    });
                }
            })
        });

        function onresize() {
            $("#editor").yqFileEdit('resize', {
                width: $(window).width(),
                height: $(window).height()
            });
        }

        function fileinfo_cms(path, mobile, callback) {
            var formData = new FormData();
            formData.append("action", "fileinfo_cms");
            formData.append("path", path);
            formData.append("mobile", mobile);
            $.ajax({
                type: 'POST',
                url: "_resource.html",
                data: formData,
                processData: false,
                contentType: false,
                dataType: "json",
                success: function (res) {
                    callback(res);
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    console.log(XMLHttpRequest.responseText);
                    callback({ error: 99, info: XMLHttpRequest.responseText });
                }
            });
        }
    </script>
</body>

</html>